home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 April: Penguin on DISC / ADC Developer CD (1993-04) (''Penguin On DISC'')_iso / Dev.CD Apr 93.iso / Utilities / MPW Interfaces 7.1 Beta / PInterfaces / DatabaseAccess.p < prev    next >
Encoding:
Text File  |  1992-08-28  |  7.1 KB  |  229 lines  |  [TEXT/MPS ]

  1.  
  2. {
  3. Created: Tuesday, September 10, 1991 at 1:01 PM
  4.  DatabaseAccess.p
  5.  Pascal Interface to the Macintosh Libraries
  6.  
  7.   Copyright Apple Computer, Inc. 1989-1991
  8.   All rights reserved
  9. }
  10.  
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.  UNIT DatabaseAccess;
  18.  INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingDatabaseAccess}
  22. {$SETC UsingDatabaseAccess := 1}
  23.  
  24. {$I+}
  25. {$SETC DatabaseAccessIncludes := UsingIncludes}
  26. {$SETC UsingIncludes := 1}
  27. {$IFC UNDEFINED UsingResources}
  28. {$I $$Shell(PInterfaces)Resources.p}
  29. {$ENDC}
  30. {$SETC UsingIncludes := DatabaseAccessIncludes}
  31.  
  32. CONST
  33.  
  34. { error and status codes }
  35. rcDBNull = -800;
  36. rcDBValue = -801;
  37. rcDBError = -802;
  38. rcDBBadType = -803;
  39. rcDBBreak = -804;
  40. rcDBExec = -805;
  41. rcDBBadSessID = -806;
  42. rcDBBadSessNum = -807;            { bad session number for DBGetConnInfo }
  43. rcDBBadDDEV = -808;                { bad ddev specified on DBInit }
  44. rcDBAsyncNotSupp = -809;        { ddev does not support async calls }
  45. rcDBBadAsyncPB = -810;            { tried to kill a bad pb }
  46. rcDBNoHandler = -811;            { no app handler for specified data type }
  47. rcDBWrongVersion = -812;        { incompatible versions }
  48. rcDBPackNotInited = -813;        { attempt to call other routine before InitDBPack }
  49.  
  50. { messages for status functions for DBStartQuery }
  51. kDBUpdateWind = 0;
  52. kDBAboutToInit = 1;
  53. kDBInitComplete = 2;
  54. kDBSendComplete = 3;
  55. kDBExecComplete = 4;
  56. kDBStartQueryComplete = 5;
  57.  
  58. { messages for status functions for DBGetQueryResults }
  59. kDBGetItemComplete = 6;
  60. kDBGetQueryResultsComplete = 7;
  61.  
  62. { data type codes }
  63. typeNone = 'none';
  64. typeDate = 'date';
  65. typeTime = 'time';
  66. typeTimeStamp = 'tims';
  67. typeDecimal = 'deci';
  68. typeMoney = 'mone';
  69. typeVChar = 'vcha';
  70. typeVBin = 'vbin';
  71. typeLChar = 'lcha';
  72. typeLBin = 'lbin';
  73. typeDiscard = 'disc';
  74.  
  75. { "dummy" types for DBResultsToText }
  76. typeUnknown = 'unkn';
  77. typeColBreak = 'colb';
  78. typeRowBreak = 'rowb';
  79.  
  80. { pass this in to DBGetItem for any data type }
  81. typeAnyType = 0;
  82.  
  83. { infinite timeout value for DBGetItem }
  84. kDBWaitForever = -1;
  85.  
  86. {  flags for DBGetItem  }
  87. kDBLastColFlag = $0001;
  88. kDBNullFlag = $0004;
  89.  
  90. TYPE
  91. DBType = OSType;
  92.  
  93. { structure for asynchronous parameter block }
  94. DBAsyncParmBlkPtr = ^DBAsyncParamBlockRec;
  95. DBAsyncParamBlockRec = RECORD
  96.  completionProc: ProcPtr;        { pointer to completion routine }
  97.  result: OSErr;                    { result of call }
  98.  userRef: LONGINT;                { for application's use }
  99.  ddevRef: LONGINT;                { for ddev's use }
  100.  reserved: LONGINT;                { for internal use }
  101.  END;
  102.  
  103. { structure for resource list in QueryRecord }
  104. ResListElem = RECORD
  105.  theType: ResType;                { resource type }
  106.  id: INTEGER;                    { resource id }
  107.  END;
  108.  
  109. ResListPtr = ^ResListArray;
  110. ResListHandle = ^ResListPtr;
  111.  
  112. ResListArray = ARRAY [0..255] OF ResListElem;
  113.  
  114. { structure for query list in QueryRecord }
  115. QueryListPtr = ^QueryArray;
  116. QueryListHandle = ^QueryListPtr;
  117.  
  118. QueryArray = ARRAY [0..255] OF Handle;
  119.  
  120. QueryPtr = ^QueryRecord;
  121. QueryHandle = ^QueryPtr;
  122. QueryRecord = RECORD
  123.  version: INTEGER;                { version }
  124.  id: INTEGER;                    { id of 'qrsc' this came from }
  125.  queryProc: Handle;                { handle to query def proc }
  126.  ddevName: Str63;                { ddev name }
  127.  host: Str255;                    { host name }
  128.  user: Str255;                    { user name }
  129.  password: Str255;                { password }
  130.  connStr: Str255;                { connection string }
  131.  currQuery: INTEGER;            { index of current query }
  132.  numQueries: INTEGER;            { number of queries in list }
  133.  queryList: QueryListHandle;    { handle to array of handles to text }
  134.  numRes: INTEGER;                { number of resources in list }
  135.  resList: ResListHandle;        { handle to array of resource list elements }
  136.  dataHandle: Handle;            { for use by query def proc }
  137.  refCon: LONGINT;                { for use by application }
  138.  END;
  139.  
  140. { structure of column types array in ResultsRecord }
  141. ColTypesPtr = ^ColTypesArray;
  142. ColTypesHandle = ^ColTypesPtr;
  143.  
  144. ColTypesArray = ARRAY [0..255] OF DBType;
  145.  
  146. { structure for column info in ResultsRecord }
  147. DBColInfoRecord = RECORD
  148.  len: INTEGER;
  149.  places: INTEGER;
  150.  flags: INTEGER;
  151.  END;
  152.  
  153. ColInfoPtr = ^ColInfoArray;
  154. ColInfoHandle = ^ColInfoPtr;
  155.  
  156. ColInfoArray = ARRAY [0..255] OF DBColInfoRecord;
  157.  
  158. { structure of results returned by DBGetResults }
  159. ResultsRecord = RECORD
  160.  numRows: INTEGER;                { number of rows in result }
  161.  numCols: INTEGER;                { number of columns per row }
  162.  colTypes: ColTypesHandle;        { data type array }
  163.  colData: Handle;                { actual results }
  164.  colInfo: ColInfoHandle;        { DBColInfoRecord array }
  165.  END;
  166.  
  167.  
  168. FUNCTION InitDBPack: OSErr;
  169.  INLINE $3F3C,$0004,$303C,$0100,$A82F;
  170. FUNCTION DBInit(VAR sessID: LONGINT;ddevName: Str63;host: Str255;user: Str255;
  171.  passwd: Str255;connStr: Str255;asyncPB: DBAsyncParmBlkPtr): OSErr;
  172.  INLINE $303C,$0E02,$A82F;
  173. FUNCTION DBEnd(sessID: LONGINT;asyncPB: DBAsyncParmBlkPtr): OSErr;
  174.  INLINE $303C,$0403,$A82F;
  175. FUNCTION DBGetConnInfo(sessID: LONGINT;sessNum: INTEGER;VAR returnedID: LONGINT;
  176.  VAR version: LONGINT;VAR ddevName: Str63;VAR host: Str255;VAR user: Str255;
  177.  VAR network: Str255;VAR connStr: Str255;VAR start: LONGINT;VAR state: OSErr;
  178.  asyncPB: DBAsyncParmBlkPtr): OSErr;
  179.  INLINE $303C,$1704,$A82F;
  180. FUNCTION DBGetSessionNum(sessID: LONGINT;VAR sessNum: INTEGER;asyncPB: DBAsyncParmBlkPtr): OSErr;
  181.  INLINE $303C,$0605,$A82F;
  182. FUNCTION DBSend(sessID: LONGINT;text: Ptr;len: INTEGER;asyncPB: DBAsyncParmBlkPtr): OSErr;
  183.  INLINE $303C,$0706,$A82F;
  184. FUNCTION DBSendItem(sessID: LONGINT;dataType: DBType;len: INTEGER;places: INTEGER;
  185.  flags: INTEGER;buffer: Ptr;asyncPB: DBAsyncParmBlkPtr): OSErr;
  186.  INLINE $303C,$0B07,$A82F;
  187. FUNCTION DBExec(sessID: LONGINT;asyncPB: DBAsyncParmBlkPtr): OSErr;
  188.  INLINE $303C,$0408,$A82F;
  189. FUNCTION DBState(sessID: LONGINT;asyncPB: DBAsyncParmBlkPtr): OSErr;
  190.  INLINE $303C,$0409,$A82F;
  191. FUNCTION DBGetErr(sessID: LONGINT;VAR err1: LONGINT;VAR err2: LONGINT;VAR item1: Str255;
  192.  VAR item2: Str255;VAR errorMsg: Str255;asyncPB: DBAsyncParmBlkPtr): OSErr;
  193.  INLINE $303C,$0E0A,$A82F;
  194. FUNCTION DBBreak(sessID: LONGINT;abort: BOOLEAN;asyncPB: DBAsyncParmBlkPtr): OSErr;
  195.  INLINE $303C,$050B,$A82F;
  196. FUNCTION DBGetItem(sessID: LONGINT;timeout: LONGINT;VAR dataType: DBType;
  197.  VAR len: INTEGER;VAR places: INTEGER;VAR flags: INTEGER;buffer: Ptr;asyncPB: DBAsyncParmBlkPtr): OSErr;
  198.  INLINE $303C,$100C,$A82F;
  199. FUNCTION DBUnGetItem(sessID: LONGINT;asyncPB: DBAsyncParmBlkPtr): OSErr;
  200.  INLINE $303C,$040D,$A82F;
  201. FUNCTION DBKill(asyncPB: DBAsyncParmBlkPtr): OSErr;
  202.  INLINE $303C,$020E,$A82F;
  203. FUNCTION DBGetNewQuery(queryID: INTEGER;VAR query: QueryHandle): OSErr;
  204.  INLINE $303C,$030F,$A82F;
  205. FUNCTION DBDisposeQuery(query: QueryHandle): OSErr;
  206.  INLINE $303C,$0210,$A82F;
  207. FUNCTION DBStartQuery(VAR sessID: LONGINT;query: QueryHandle;statusProc: ProcPtr;
  208.  asyncPB: DBAsyncParmBlkPtr): OSErr;
  209.  INLINE $303C,$0811,$A82F;
  210. FUNCTION DBGetQueryResults(sessID: LONGINT;VAR results: ResultsRecord;timeout: LONGINT;
  211.  statusProc: ProcPtr;asyncPB: DBAsyncParmBlkPtr): OSErr;
  212.  INLINE $303C,$0A12,$A82F;
  213. FUNCTION DBResultsToText(results: ResultsRecord;VAR theText: Handle): OSErr;
  214.  INLINE $303C,$0413,$A82F;
  215. FUNCTION DBInstallResultHandler(dataType: DBType;theHandler: ProcPtr;isSysHandler: BOOLEAN): OSErr;
  216.  INLINE $303C,$0514,$A82F;
  217. FUNCTION DBRemoveResultHandler(dataType: DBType): OSErr;
  218.  INLINE $303C,$0215,$A82F;
  219. FUNCTION DBGetResultHandler(dataType: DBType;VAR theHandler: ProcPtr;getSysHandler: BOOLEAN): OSErr;
  220.  INLINE $303C,$0516,$A82F;
  221.  
  222.  
  223. {$ENDC} { UsingDatabaseAccess }
  224.  
  225. {$IFC NOT UsingIncludes}
  226.  END.
  227. {$ENDC}
  228.  
  229.